<template>
  <div>
    <div class="message">
      <div class="header">热门帖子</div>
      <div class="message-list">
        <div
          class="img-list"
          v-for="(item, index) in dataList"
          :key="index"
          @click="openLink(item)"
        >
          <img class="image" :src="item.file_path" alt>
          <p class="massage-header one-txt-cut">{{ item.title }}</p>
          <div class="peronNum">
            <span class="iconfont icon-dianzan"></span>
            <span class="icon-text">{{item.like_nums || 0}}</span>
            <span class="iconfont icon-xiaoxi"></span>
            <span class="icon-text">{{item.comment_nums || 0}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getListPortalTops } from "@/api/home";

export default {
  name: "OtherItem",
  data() {
    return {
      listQuery: {
        current: 1,
        limit: 8,
        company_id: localStorage.getItem("companyId") - 0
      },
      dataList: []
    };
  },
  methods: {
    openLink(item) {
      if (item.type == "draw") {
        this.$router.push({ path: "/Trunplate1", query: { drawId: item.id } });
      }
      if (item.type == "active") {
        this.$router.push({
          path: "/ActivityDetail",
          query: { id: item.id, status: item.active_status, name: "home" }
        });
      }
      if (item.type == "article") {
        this.$router.push({ path: "/CommunityDetail", query: { id: item.id, name: "article" } });
      }
      if (item.type == "proposal") {
        this.$router.push({ path: "/proposalDetail", query: { id: item.id, name: "proposal" } });
      }
      if (item.vote_type == 1) {
        this.$router.push({ path: "/VoteTypeTwo", query: { id: item.id } });
      }
      if (item.vote_type == 2) {
        this.$router.push({ path: "/VoteTypeThree", query: { id: item.id } });
      }
      if (item.type == "questionnaire") {
        this.$router.push({ path: "/SurveyDetails", query: { id: item.id } });
      }
    },
    async initList() {
      let query = Object.assign({}, this.listQuery);
      let res = await getListPortalTops(query);
      let result = res.data;
      if (result.status == 100) {
        this.dataList = result.data.rows;
      }
    }
  },
  created() {
    setTimeout(() => {
      this.initList();
    }, 1000);
  }
};
</script>

<style lang="scss" scoped>
@import "other";
</style>
